package com.htrq.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.ParseException;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.htrq.entity.JQHistory;
import com.htrq.entity.Page;
import com.htrq.entity.TotalMoney;
import com.htrq.service.JQhistoryService;

@Controller
@RequestMapping("jsp/basinfo")
public class JQhistoryController {
	
	@Resource
	private JQhistoryService jqHService;
	
	@RequestMapping("getAlljqh")
	@ResponseBody
	public String getCountjq(JQHistory jqh,Page page,HttpServletResponse response) throws IOException, ParseException{
		List<JQHistory> list=jqHService.getAlljqh(jqh,page);
		String str = JSON.toJSONString(list);
		Long count=jqHService.getTotal(jqh);
		String json = "{total:" + count + ",jqhs:" + str + "}";
		response.setContentType("text/html;charset=utf8");
		PrintWriter out = response.getWriter();
		out.print(json);
		return null;
	}
	
	@RequestMapping("getTotalnumandmoney")
	@ResponseBody
	public String getTotalnumandmoney(JQHistory jqh,HttpServletResponse response) throws IOException{
		TotalMoney tota=jqHService.getMoneyandNum(jqh);
		String str = JSON.toJSONString(tota);
		response.setContentType("text/html;charset=utf8");
		PrintWriter out = response.getWriter();
		out.print(str);
		return null;
	}
}
